import Mock from 'mockjs'; // 引入mockjs
import Qs from 'qs';
const Random = Mock.Random;  // Mock.Random 是一个工具类，用于生成各种随机数据
const VITE_API_URL = import.meta.env.VITE_APP_BASE_API;


// 接口/mall4cloud_product/ua/app/hot_search/list
Mock.mock(
  new RegExp(VITE_API_URL + '/mall4cloud_product/ua/app/hot_search/list' + '.*'),
  'get',
  (options?: object): any => {
    let tempObj = Mock.mock({
      "hotSearchList|1-10": [
        {
          "categoryId|+1": [
            Random.guid(),
            Random.guid(),
            Random.guid(),
          ],
          'content|+1':[
            Random.ctitle(2,8),
            Random.ctitle(2,8),
            Random.ctitle(2,8)
          ]
        }
      ],
      pages:Random.integer(1,10),
      total:Random.integer(2,10)
    })
    console.log(tempObj,'/mall4cloud_product/ua/app/hot_search/list')
    let result = [ ...tempObj.hotSearchList]
    return result
  }
)

// 登录接口/mall4cloud_search/ua/search/simple_page
Mock.mock(
  new RegExp(VITE_API_URL + '/mall4cloud_search/ua/search/simple_page' + '.*'),
  'get',
  (options?: object): any => {
    let tempObj = Mock.mock({
      "spus|1-10": [
        {
          "spuId|+1": [
            Random.guid(),
            Random.guid(),
            Random.guid(),
          ],
          'mainImgUrl|+1':[
            Random.image('200x100', '#FF6600'),
            Random.image('200x100', '#FF6600'),
            Random.image('200x100', '#FF6600')
          ],
          'spuName|+1':[Random.cname(),Random.cname(),Random.cname()],
          'priceFee|+1':[Random.integer(1000, 5000),Random.integer(1000, 5000),Random.integer(1000, 5000)]
        }
      ]
    })
    let result = {
      list:[
        tempObj
      ],
      pages:Random.integer(1,10)
    }
    console.log(result,'/mall4cloud_search/ua/search/simple_page')
    return result
  }
)
